Skip to content

Comments

Fix broadcast_json to isolate per-connection send failures#21

Merged
JohnCHarrington merged 2 commits intorefactor-python-codefrom
copilot/sub-pr-17
Feb 19, 2026
Merged

Fix broadcast_json to isolate per-connection send failures#21
JohnCHarrington merged 2 commits intorefactor-python-codefrom
copilot/sub-pr-17

Conversation

Copy link

Copilot AI commented Feb 19, 2026

A single failing WebSocket in broadcast_json would raise and abort the entire broadcast loop, leaving dead sockets in active_connections and silently dropping messages to all other clients.

Changes

  • ConnectionManager.broadcast_json: Iterate over a snapshot of active_connections and wrap each send_json in a per-connection try/except — failed sends log a warning and trigger disconnect() to evict the dead socket
async def broadcast_json(self, data) -> None:
    for connection in list(self.active_connections):
        try:
            await connection.send_json(data)
        except Exception as e:
            log.warning(f"WebSocket send failed, disconnecting client: {e}")
            await self.disconnect(connection)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: JohnCHarrington <1857365+JohnCHarrington@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on Python code refactor and workflow updates Fix broadcast_json to isolate per-connection send failures Feb 19, 2026
@JohnCHarrington JohnCHarrington marked this pull request as ready for review February 19, 2026 11:27
@JohnCHarrington JohnCHarrington merged commit 5a13249 into refactor-python-code Feb 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants